name: CI

on: [push, pull_request]

jobs:
  ci:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x, 14.x, 16.x, 18.x, 20.x]

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 10
      - name: Use Node.js 18.x to build
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
      - run: npm install
      - run: npm run build
      - run: rm -rf node_modules
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install
      - run: npm run test
        env:
          CI: true
      - run: npm run lint
        if: matrix.node-version == '18.x'
      - run: npm run docs:diff
        if: matrix.node-version == '18.x'
      - run: npm run test:node
        if: matrix.node-version >= '18.x'
      - run: npm run test:pack
        if: matrix.node-version >= '18.x'
